home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 629 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. From: Hayden Schultz <haydens@tiac.net>
  2. Message-ID: <313BD2CA.7DBD@tiac.net>
  3. X-Original-Date: Tue, 05 Mar 1996 00:36:10 -0500
  4. Path: in2.uu.net!bounce-back
  5. Date: 05 Mar 96 07:58:26 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: STL pop_back()
  9. Organization: Ptech Inc
  10. References: <4h4hmr$41o@news.rwth-aachen.de> <4h78mr$alj@engnews1.Eng.Sun.COM>
  11. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMTv0M+EDnX0m9pzZAQHxVwF/ezH/EY3HMU5OrQn6beCaKvlBSCHCqXrJ
  14.     J50/k9SoXlDNVdo5mFbnDi58nRNub+HY
  15.     =Bzlr
  16.  
  17. According to _STL Tutorial and Reference Guide_ by Musser and Saini
  18. (a very good book, btw), the following functions are defined:
  19.  
  20. template <class T> void vector<t>::pop_back();
  21. template <class T> void deque<t>::pop_back();
  22. template <class T> void deque<t>::pop_front();
  23. template <class T> void list<t>::pop_back();
  24. template <class T> void list<t>::pop_front();
  25.  
  26. Other classes may have pop functions, I dunno.
  27.  
  28. Why don't the pop functions return a copy of the object before they
  29. blow it away? Another possibility, I suppose, would be an auto_ptr<T>
  30. so that the object is deleted if it's not used. An auto_ptr<T> is
  31. about as efficient as deleting it in the pop function, it just changes
  32. the time it's deleted (which isn't guaranteed anywhere I've read
  33. anyway).
  34.  
  35. Why call the methods push and pop if it doesn't act like a stack?
  36.  
  37. It's not really a big deal (it's easy enough to write my own adapter).
  38. I'm just curious.
  39.  
  40.     Thanks,
  41.  
  42.     Hayden Schultz
  43.     Ptech, Inc.
  44.     haydens@tiac.net
  45.     hayden@ptechinc.com
  46. ---
  47. [ To submit articles: try just posting with your news-reader.
  48.                       If that fails, use mailto:std-c++@ncar.ucar.edu
  49.   FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  50.   Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  51.   Comments? mailto:std-c++-request@ncar.ucar.edu.
  52. ]
  53.